import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/models/user/xindong_kongjian_user.dart';
import 'package:xindong/routes/userspace/view/xindong_kongjian_title_container.dart';
import 'package:xindong/utils/xindong_text_util.dart';
import 'package:xindong/widgets/common/xindong_round_image.dart';
import 'package:xindong/widgets/image/browser/xindong_images_browser.dart';
import 'package:xindong/widgets/image/image_grid/xindong_image_grid_view.dart';

class XinDongKongJianInfoBasic extends StatelessWidget {
  final XinDongSpaceUser model;

  const XinDongKongJianInfoBasic({super.key, required this.model});

  @override
  Widget build(BuildContext context) {
    const double spacing = 8.0;
    final dataList = ["${model.sex} ${model.age}岁"];
    if (!TextUtil.isEmpty(model.city)) {
      dataList.add("所在地：${model.city}");
    }
    if (!TextUtil.isEmpty(model.emotion)) {
      dataList.add("${model.emotion}");
    }
    if (!TextUtil.isEmpty(model.stature)) {
      dataList.add("${model.stature}cm");
    }
    if (!TextUtil.isEmpty(model.weight)) {
      dataList.add("${model.weight}kg");
    }
    if (!TextUtil.isEmpty(model.education_background)) {
      dataList.add("${model.education_background}");
    }
    if (!TextUtil.isEmpty(model.monthly_salary)) {
      dataList.add("年收入：${model.monthly_salary}");
    }
    if (!TextUtil.isEmpty(model.occupation)) {
      dataList.add("${model.occupation}");
    }
    if (!TextUtil.isEmpty(model.is_house_purchase)) {
      dataList.add("${model.is_house_purchase}");
    }
    if (!TextUtil.isEmpty(model.is_car_purchase)) {
      dataList.add("${model.is_car_purchase}");
    }
    final list = dataList.map((e) => _buildItem(e)).toList();
    return XinDongKongJianTitleContainer(
      title: '基本资料',
      children: [Wrap(spacing: spacing, runSpacing: spacing, children: list)],
    );
  }

  Widget _buildItem(String name) {
    return Container(
      height: 29,
      padding: const EdgeInsets.only(left: 15, right: 15),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(26),
        border: Border.all(color: DZColors.hexStringColor("#C9C9C9"), width: 0.5),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            name,
            textAlign: TextAlign.center,
            maxLines: 1,
            style: const TextStyle(fontSize: 12, color: DZColors.titleColor, height: 1.2),
          ),
        ],
      ),
    );
  }
}
